package com.exmaple.dynamicapp;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.exmaple.dynamicapp.annotation.OnClick;
import com.exmaple.dynamicapp.annotation.OnLongClick;
import com.exmaple.dynamicapp.annotation.OnTouch;
import com.exmaple.dynamicapp.injection.InjectionUtils;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        InjectionUtils.bindViewEvent(this);

    }


    @OnClick(R.id.btn_hello)
    public void onClicked(View view){
        String text= ((TextView)view).getText().toString();
        Log.i(TAG, "onClicked: "+text);
        Toast.makeText(this,text,Toast.LENGTH_SHORT).show();
    }

    @OnLongClick(R.id.btn_hello)
    public boolean onLongClicked(View view){
        String text= ((TextView)view).getText().toString();
        Log.i(TAG, "onLongClicked: "+text);
        Toast.makeText(this,text,Toast.LENGTH_LONG).show();
        return true;
    }

    @OnTouch(R.id.btn_hello)
    public boolean onTouched(View view, MotionEvent event){
        String text= ((TextView)view).getText().toString();
        Log.i(TAG, "onTouched: "+text);
        Toast.makeText(this,text,Toast.LENGTH_LONG).show();
        return false;
    }
}